package com.ruoyi.smartcity.anfang.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.smartcity.anfang.domain.AnfangJingbao;
import com.ruoyi.smartcity.anfang.service.IAnfangJingbaoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 警报日志Controller
 * 
 * @author ruoyi
 * @date 2025-03-09
 */
@RestController
@RequestMapping("/smartcity/anfang/jingbao")
public class AnfangJingbaoController extends BaseController
{
    @Autowired
    private IAnfangJingbaoService anfangJingbaoService;

    /**
     * 查询警报日志列表
     */
    @RequiresPermissions("anfang:jingbao:list")
    @GetMapping("/list")
    public TableDataInfo list(AnfangJingbao anfangJingbao)
    {
        startPage();
        List<AnfangJingbao> list = anfangJingbaoService.selectAnfangJingbaoList(anfangJingbao);
        return getDataTable(list);
    }

    /**
     * 导出警报日志列表
     */
    @RequiresPermissions("anfang:jingbao:export")
    @Log(title = "警报日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AnfangJingbao anfangJingbao)
    {
        List<AnfangJingbao> list = anfangJingbaoService.selectAnfangJingbaoList(anfangJingbao);
        ExcelUtil<AnfangJingbao> util = new ExcelUtil<AnfangJingbao>(AnfangJingbao.class);
        util.exportExcel(response, list, "警报日志数据");
    }

    /**
     * 获取警报日志详细信息
     */
    @RequiresPermissions("anfang:jingbao:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(anfangJingbaoService.selectAnfangJingbaoById(id));
    }

    /**
     * 新增警报日志
     */
    @RequiresPermissions("anfang:jingbao:add")
    @Log(title = "警报日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AnfangJingbao anfangJingbao)
    {
        return toAjax(anfangJingbaoService.insertAnfangJingbao(anfangJingbao));
    }

    /**
     * 修改警报日志
     */
    @RequiresPermissions("anfang:jingbao:edit")
    @Log(title = "警报日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AnfangJingbao anfangJingbao)
    {
        return toAjax(anfangJingbaoService.updateAnfangJingbao(anfangJingbao));
    }

    /**
     * 删除警报日志
     */
    @RequiresPermissions("anfang:jingbao:remove")
    @Log(title = "警报日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(anfangJingbaoService.deleteAnfangJingbaoByIds(ids));
    }
}
